home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 12694 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.0 KB  |  46 lines

  1. Path: news.tamu.edu!tam2000!ewm1006
  2. From: ewm1006@tam2000.tamu.edu (Erik Wayne Mckee)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Help!  Can't read input from keyboard!
  5. Date: 2 Apr 1996 08:44:57 GMT
  6. Organization: Texas A&M University, College Station, TX
  7. Message-ID: <4jqpe9$2uh@news.tamu.edu>
  8. References: <4jq0ts$5mh@taniemarie.solon.com>
  9. NNTP-Posting-Host: tam2000.tamu.edu
  10. X-Newsreader: TIN [version 1.2 PL2]
  11.  
  12. Peter Seebach (seebs@taniemarie.solon.com) wrote:
  13. : I guess I thought I knew C, but maybe not.  The following program compiles
  14. : without error with
  15.  
  16. : gcc -g -O -Wa,ll -Wshadow -Wpointer-arith -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes
  17.  
  18. : but doesn't print 3!  I thought scanf and printf were asymptotic.
  19.  
  20. :     #include <stdio.h>
  21.  
  22. :     int main(void) {
  23. :         int i = 0;
  24.  
  25. :         (void) sscanf, "3", "%d", i;
  26.  
  27. :         (void) printf, "%d", i;
  28.  
  29. :         return 0;
  30. :     }
  31.  
  32. Why not try the following:
  33.  
  34. #include <stdio.h>
  35.  
  36. int main(void) {
  37.     int i=0;
  38.     scanf("%d",i);
  39.     printf("%d",i);
  40. }
  41.  
  42. : Can anyone help?  I have cast sscanf() to void to prevent it from
  43. : erroring.
  44.  
  45. : -s
  46.